<template>
  <div>
    <div class="search_form">
			<div>
        <el-date-picker
          v-model="searchForm.workDate"
          type="date"
          size="mini"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
				<el-select
					size="mini"
					clearable
					placeholder="请选择班次"
					v-model="searchForm.workTime"
					class="others"
					popper-class="selectClass"
				>
					<el-option v-for="(item, index) in workTimeList" :key="index" :label="item.dictLabel" :value="item.dictValue"></el-option>
				</el-select>

				<el-button class="search_btn" type="primary" icon="el-icon-search" size="mini" @click="searchData">查询</el-button>
				<el-button icon="el-icon-refresh-right" size="mini" @click="resetSearch">重置</el-button>
			</div>
      <div>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:addPlan']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="importOrder">导入作业指令</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updatePlanById']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="saveWorkPlan">保存</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateStatus']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="auditWorkPlan">审核</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:deleteById']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="deletehandlerClick">删除</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:copyById']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="copyWorkPlan">复制</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:copy']" v-if="isShowWorkPlanbtn" type="primary" size="mini" @click="importWorkPlan">导入上班次</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateApplicationPlan']" v-if="isShowOddJobbtn" type="primary" size="mini" @click="saveOddJob">保存</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateStatus']" v-if="isShowOddJobbtn" type="primary" size="mini" @click="auditOddJob">审核</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updatePlanById']" v-if="isShowOpenPort" type="primary" size="mini" @click="saveOpenPort">保存</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateStatus']" v-if="isShowOpenPort" type="primary" size="mini" @click="auditOpenPort">审核</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateTransportPlan']" v-if="isShowTra" type="primary" size="mini" @click="savetransshipment">保存</el-button>
        <el-button v-hasPermi="['dispatchManagement:TDisWorkPlan:updateStatus']" v-if="isShowTra" type="primary" size="mini" @click="audittransshipment">审核</el-button>
      </div>
    </div>
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick(activeName)">
      <el-tab-pane label="船舶计划" name="first">
        <!-- 主列表table -->
        <BaseTableCheck 
          ref="showFrontEdgeForEdit"
          :loading="loading"
          :data="tableData"
          :columns="columns" 
          :tableHT="tableHeight" 
          @detailsdb="handlerClickdb"
          @details="handlerClickA"
          :pagination="queryall" 
          @size-change="sizeChange" 
          @current-change="pageChange" 
          @checkId="workTaskSelChange"></BaseTableCheck>
      </el-tab-pane>
      <el-tab-pane label="零工计划" name="second">
        <!-- 主列表table -->
        <BaseTableCheck 
          ref="oddJobPlan"
          :loading="oloading"
          :data="oddJobTableData"
          :columns="oddJobColumns" 
          :tableHT="tableHeight" 
          @details="handlerClickB"
          @detailsdb="oddJobhandlerClickdb" 
          :pagination="false" 
          @checkId="oddJobselectCheck"></BaseTableCheck>
      </el-tab-pane>
      <el-tab-pane label="集疏港计划" name="third">
        <!-- 主列表table -->
        <BaseTableCheck 
          ref="openPort"
          :loading="ploading"
          :data="openPortTableData"
          :columns="openPortColumns" 
          :tableHT="tableHeight" 
          @details="handlerClickC"
          @detailsdb="openPortHandlerClickdb" 
          :pagination="false" 
          @checkId="openPortselectCheck"></BaseTableCheck>
      </el-tab-pane>
      <el-tab-pane label="转运计划" name="four">
        <!-- 主列表table -->
        <BaseTableCheck 
          ref="transshipment"
          :loading="tloading"
          :data="transshipmentTableData"
          :columns="transshipmentColumns" 
          :tableHT="tableHeight" 
          @details="handlerClickD"
          @detailsdb="transshipmentHandlerClickdb" 
          :pagination="false" 
          @checkId="transshipmentselectCheck"></BaseTableCheck>
      </el-tab-pane>
    </el-tabs>
    <el-drawer title="导入作业指令" custom-class="importBus" :visible.sync="isShow" size="78%" :before-close="importBeforeClose">
      <div v-if="isShow" class="drawerContent">
        <import-trust :closeDrawer="closeDrawer"></import-trust>
      </div>
    </el-drawer>
    <el-drawer title="导入上一班次" custom-class="importBus" :visible.sync="isShowPaln" size="78%">
      <div v-if="isShowPaln" class="drawerContent">
        <importWorkPlan :workTimeList="workTimeList" :closeDrawer="closeDrawer"></importWorkPlan>
      </div>
    </el-drawer>
    
  </div>
</template>
<script>
import BaseTableCheck from '@/components/BaseTable/baseTablecheck'
import BaseTable from '@/components/BaseTable'
import publicapi from '@/api/public/index'
import importTrust from './subPage/importTrust'
import api from '@/api/Dispatch/operationPlan/index'
import importWorkPlan from './subPage/importWorkPlan'
export default{
  components: { BaseTable,BaseTableCheck,importTrust,importWorkPlan },
  data () {
    return {
      //查询条件
      searchForm: {
        workDate: '',
        workTime: '',
      },
      workTimeList: [], // 班次
      menuArr: [],
      activeName: 'first', // tab选择页
      loading: false, // 主列表loading
      // 主列表data
      tableData: [],
      // 主列表列
      columns: [
        {
          prop: 'planNo',
          label: '编号',
          width: 140
        },
        {
          prop: 'approvalStatus',
          label: '状态',
          render(h,params) {
            if (params.row.approvalStatus == '1') {
              return h('el-tag', {
                props: {
                  size: 'mini'
                },
                domProps: {
                  innerHTML: '未审核'
                }
              })
            } else if (params.row.approvalStatus == '2') {
              return h('el-tag', {
                props: {
                  size: 'mini',
                  type: 'success'
                },
                domProps: {
                  innerHTML: '已审核'
                }
              })
            }
          }
        },
        {
          prop: 'processName',
          label: '作业过程'
        },
        {
          prop: 'nameVoyage',
          label: '船名航次',
          width: 120
        },
        {
          prop: 'cabinNo',
          label: '舱口',
          width: 120,
          render: (h,params) => {
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-select
										v-model={params.row.cabinNos}
										multiple
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectCabinNo(e,params.row.index,'ship')}
									>
										{this.hatchNoList 
											? this.hatchNoList.map((item, index) => {
													return <el-option key={index} label={item} value={item}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cabinNo}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cargoCategoryName',
          label: '货种'
        },
        {
          prop: 'customerName',
          label: '客户名称',
          isShort: true,
        },
        {
          prop: 'loadUnload',
          label: '装卸'
        },
        {
          prop: 'berthNo',
          label: '泊位'
        },
        {
          prop: 'storehouseNameSource',
          label: '起始区域',
        },
        {
          prop: 'storehouseNameTarget',
          label: '终点区域',
        },
        {
          prop: 'deptName',
          label: '作业工段',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-select
										v-model={params.row.deptCode}
										class="no-border"
										value-key="id"
										clearable
                    multiple
                    collapse-tags
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelect(e, params.row,params.row.index,'deptName')}
									>
										{this.deptList 
											? this.deptList.map((item, index) => {
													return <el-option key={index} label={item.deptName} value={item.deptCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.deptName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cooperationName',
          label: '协力队',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-select
										v-model={params.row.cooperationCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelect(e, params.row,params.row.index,'cooperationName')}
									>
										{this.operativeTeamList.length != 0
											? this.operativeTeamList.map((item, index) => {
													return <el-option key={index} label={item.cooperationName} value={item.cooperationCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cooperationName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyFront',
          label: '前沿',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
                  return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyFrontList[params.row.index], "num", e)
                            console.log(this.tallyFrontList[params.row.index])
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyFrontList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.colsePopoer}
                    onShow={e => this.setFrontData(params.row.tallyFrontList,'front')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyFrontList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTeamForEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyFront}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择前沿"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.cleardowmTeamDetail("tallyFront", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyFront", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyFront}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'transport',
          label: '转运',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.transportList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.transportList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
                    v-model={this.colsetransport}
                    onShow={e => this.setFrontData(params.row.transportList,'transport')}
										popper-class="workTaskEditPopover"
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.transportList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTeamForEdit("transport", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("transport", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.transport}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择转运"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.cleardowmTeamDetail("transport", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("transport", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.transport}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyBack',
          label: '后场',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyBackList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyBackList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.colseback}
                    onShow={e => this.setFrontData(params.row.tallyBackList,'tallyBack')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyBackList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTeamForEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyBack}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择后场"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.cleardowmTeamDetail("tallyBack", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyBack", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyBack}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'supporting',
          label: '辅助',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.supportingList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.supportingList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.colsesupport}
                    onShow={e => this.setFrontData(params.row.supportingList,'supporting')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.supportingList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTeamForEdit("supporting", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("supporting", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.supporting}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择辅助"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.cleardowmTeamDetail("supporting", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("supporting", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.supporting}</span>
								)}
							</div>
						)
          }
        },
        // {
        //   prop: 'laborDispatch',
        //   label: '劳务',
        //   width: 130,
        //   render: (h,params) => {
        //     let teamListColumns = [
				// 			{
				// 				prop: "deptName",
				// 				label: "劳务队",
				// 			},
				// 			{
				// 				prop: "num",
				// 				label: "人数",
				// 				render: (h, params) => {
				// 					return h("el-input", {
				// 						props: {
				// 							value: params.row.num,
				// 							type: "text",
				// 							size: "mini",
				// 							placeholder: "请输入",
				// 						},
				// 						on: {
				// 							input: e => {
				// 								this.$set(this.laborDispatchList[params.row.index], "num", e)
				// 							},
				// 						},
				// 					})
				// 				},
				// 			},
				// 		]
        //     return (
				// 			<div>
				// 				{this.editIndex === params.row.index ? (
				// 					<el-popover
				// 						placement="bottom"
				// 						width="300"
				// 						trigger="click"
				// 						ref="showTeamOneForEdit"
				// 						popper-class="workTaskEditPopover"
        //             v-model={this.colselabour}
        //             onShow={e => this.setlabourData(params.row.laborDispatchList)}
				// 					>
				// 						<div class="box-infoNew">
				// 							<BaseTable
				// 								data={this.laborDispatchList}
				// 								columns={teamListColumns}
				// 								pagination={false}
				// 								tableHeight={500}
				// 							></BaseTable>
				// 							<div class="btn-sureNew" style={this.btnSureNew}>
				// 								<el-button
				// 									type="primary"
				// 									onClick={e => this.saveLabourData("laborDispatch", params, params.row.index)}
				// 									size="mini"
				// 								>
				// 									确定
				// 								</el-button>
				// 								<el-button
				// 									type="info"
				// 									style={this.btnNew}
				// 									onClick={e => this.cancelTeamForEdit("laborDispatch", params, params.row.index)}
				// 									size="mini"
				// 								>
				// 									取消
				// 								</el-button>
				// 							</div>
				// 						</div>
				// 						<el-input
				// 							v-model={params.row.laborDispatch}
				// 							autocomplete="off"
				// 							size="small"
				// 							slot="reference"
				// 							placeholder="请选择劳务队别"
				// 							suffix-icon="el-icon-arrow-down"
				// 							class="no-border"
				// 							clearable
				// 							onClear={e => this.cleardowmTeamDetail("laborDispatch", params.row.index)}
				// 							onInput={e => this.inputdowmTeamDetail("laborDispatch", e, params.row.index)}
				// 						></el-input>
				// 					</el-popover>
				// 				) : (
				// 					<span>{params.row.laborDispatch}</span>
				// 				)}
				// 			</div>
				// 		)
        //   }
        // },
        {
          prop: 'laborDispatch',
          label: '劳务',
          render: (h,params) => {
            return (
              <div>
                {this.editIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.laborDispatch,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.tableData[params.row.index], "laborDispatch", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.laborDispatch}</span>
								)}
              </div>
            )
          }
        },
        {
          prop: 'foreignTallyCompanyName',
          label: '外理单位'
        },
        {
          prop: 'tallyClerk',
          label: '理货员',
        },
        {
          prop: 'ruler',
          label: '检尺员',
        },
        {
          prop: 'instructorName',
          label: '指导员',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.editIndex === params.row.index ? (
									<el-select
										v-model={params.row.instructorName}
										filterable
										class="no-border"
										value-key="instructorBy"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelect(e, params.row,params.row.index,'instructorName')}
									>
										{this.guideList.length != 0
											? this.guideList.map((item, index) => {
													return <el-option key={index} label={item.instructorName} value={item}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.instructorName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'workloadPlan',
          label: '计划量',
          render: (h,params) => {
            return (
              <div>
                {this.editIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.workloadPlan,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.tableData[params.row.index], "workloadPlan", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.workloadPlan}</span>
								)}
              </div>
            )
          }
        },
        {
          prop: 'endTimePlan',
          label: '计划完工时间',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.editIndex === params.row.index ? 
                  h('el-date-picker', {
						        props: {
						        	value: params.row.endTimePlan,
						        	type: "datetime",
						        	size: "mini",
						        	placeholder: "请选择",
                      format: 'yyyy-MM-dd hh:mm',
                      valueFormat: 'yyyy-MM-dd hh:mm',
						        },
                    domProps: {
                      style: 'width: 100%'
                    },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.tableData[params.row.index], "endTimePlan", e)
						        	},
						        },
                  }) : (
                    <span>{params.row.endTimePlan}</span>
                  )
                }
              </div>
            )
          }
        },
        {
          prop: 'remark',
          label: '作业要求',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.editIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.remark,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.tableData[params.row.index], "remark", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.remark}</span>
								)}
              </div>
            )
          }
        },
      ],
      tableHeight: window.innerHeight - 250,
      // 页码
      queryall: {
        totalNum: 0,
        startpage: 1,
        pagesize: 15
      },
      editIndex: -1, // 选中需要编辑的列下标
      teamListForEdit: [], // 劳务信息
      btnSureNew: {
				display: "flex",
				alignItems: "center",
				justifyContent: "center",
			},
      isShow: false, // 是否显示导入作业指令抽屉
      deptList: [], // 作业工段
      operativeTeamList: [], //协力队list
      labourList: [], // 劳务队
      machineList: [], // 机械类型
      machineTypeList: [],// 门机
      guideList: [], // 指导员list
      tallyFrontList: [], //前沿
      tallyBackList: [], //后场
      laborDispatchList: [],  //劳务
      transportList: [],  // 转运
      supportingList: [], // 辅助
      frontDoorMachineList: [], //前沿门机
      colsePopoer: false,
      colseback: false,
      colsetransport: false,
      colsesupport: false,
      colselabour: false,
      checkData: [], // 主列表选中的复选框
      isShowPaln: false, // 是否显示上一班次抽屉
      oloading: false,
      oddJobTableData: [], // 零工table
      oddJobColumns: [
        {
          prop: 'planNo',
          label: '编号',
          width: 120
        },
        {
          prop: 'approvalStatus',
          label: '状态',
          render(h,params) {
            if (params.row.approvalStatus == '1') {
              return h('el-tag', {
                props: {
                  size: 'mini'
                },
                domProps: {
                  innerHTML: '未审核'
                }
              })
            } else if (params.row.approvalStatus == '2') {
              return h('el-tag', {
                props: {
                  size: 'mini',
                  type: 'success'
                },
                domProps: {
                  innerHTML: '已审核'
                }
              })
            }
          }
        },
        {
          prop: 'processName',
          label: '作业过程',
        },
        {
          prop: 'nameVoyage',
          label: '船名航次',
          width: 120
        },
        {
          prop: 'cabinNo',
          label: '舱口',
          width: 120,
          render: (h,params) => {
            return (
							<div>
								{this.oddIndex === params.row.index ? (
									<el-select
										v-model={params.row.cabinNos}
										multiple
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectCabinNo(e,params.row.index,'odd')}
									>
										{this.hatchNoList 
											? this.hatchNoList.map((item, index) => {
													return <el-option key={index} label={item} value={item}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cabinNo}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cargoCategoryName',
          label: '货种',
        },
        {
          prop: 'workContent',
          label: '作业内容',
        },
        {
          prop: 'deptName',
          label: '作业工段',
          render: (h,params) => {
            return (
							<div>
								{this.oddIndex === params.row.index ? (
									<el-select
										v-model={params.row.deptCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectOddJob(e,params.row,params.row.index,'deptName')}
									>
										{this.deptList 
											? this.deptList.map((item, index) => {
													return <el-option key={index} label={item.deptName} value={item.deptCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.deptName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'processName',
          label: '协力队',
          render: (h,params) => {
            return (
							<div>
								{this.oddIndex === params.row.index ? (
									<el-select
										v-model={params.row.cooperationCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectOddJob(e,params.row,params.row.index,'cooperationName')}
									>
										{this.operativeTeamList.length != 0
											? this.operativeTeamList.map((item, index) => {
													return <el-option key={index} label={item.cooperationName} value={item.cooperationCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cooperationName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'supporting',
          label: '机械',
          width: 120,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
                  return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.supportingList[params.row.index], "num", e)
                            console.log(this.supportingList[params.row.index])
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.supportingList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.oddIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.colsesupport}
                    onShow={e => this.setFrontData(params.row.supportingList,'supporting')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.supportingList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureMachineOddJob('supporting',params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit('supporting',params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.supporting}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择前沿"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearOddJobDetail(params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.supporting}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'laborDispatch',
          label: '劳务',
        },
        {
          prop: 'applyDeptName',
          label: '申请单位',
        },
        {
          prop: 'remark',
          label: '备注',
        },
      ], //
      oddJobCheck: [], // 零工选中的复选框
      oddIndex: -1, //零工选中行的index
      isShowWorkPlanbtn: true, // 船舶计划按钮
      isShowOddJobbtn: false, // 零工计划按钮
      isShowOpenPort: false, // 集疏港计划按钮
      isShowTra: false,     // 转运计划按钮
      ploading: false,
      portIndex: -1, // 集疏港选中的下标
      hatchNoList: ['1','2','3','4','5','6','7','8'],
      openPortTableData: [], // 集疏港data
      openPortColumns: [
        {
          prop: 'planNo',
          label: '编号',
          width: 140
        },
        {
          prop: 'approvalStatus',
          label: '状态',
          render(h,params) {
            if (params.row.approvalStatus == '1') {
              return h('el-tag', {
                props: {
                  size: 'mini'
                },
                domProps: {
                  innerHTML: '未审核'
                }
              })
            } else if (params.row.approvalStatus == '2') {
              return h('el-tag', {
                props: {
                  size: 'mini',
                  type: 'success'
                },
                domProps: {
                  innerHTML: '已审核'
                }
              })
            }
          }
        },
        {
          prop: 'processName',
          label: '作业过程'
        },
        {
          prop: 'nameVoyage',
          label: '船名航次',
          width: 120
        },
        {
          prop: 'cabinNo',
          label: '舱口',
          width: 120,
          render: (h,params) => {
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-select
										v-model={params.row.cabinNos}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectCabinNo(e,params.row.index,'port')}
									>
										{this.hatchNoList 
											? this.hatchNoList.map((item, index) => {
													return <el-option key={index} label={item} value={item}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cabinNo}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cargoCategoryName',
          label: '货种',
        },
        {
          prop: 'customerName',
          label: '货代',
          isShort: true,
        },
        {
          prop: 'loadUnload',
          label: '装卸'
        },
        {
          prop: 'berthNo',
          label: '泊位'
        },
        {
          prop: 'storehouseNameSource',
          label: '起始区域',
        },
        {
          prop: 'storehouseNameTarget',
          label: '终点区域',
        },
        {
          prop: 'deptName',
          label: '作业工段',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-select
										v-model={params.row.deptCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectPort(e, params.row,params.row.index,'deptName')}
									>
										{this.deptList 
											? this.deptList.map((item, index) => {
													return <el-option key={index} label={item.deptName} value={item.deptCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.deptName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cooperationName',
          label: '协力队',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-select
										v-model={params.row.cooperationCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectPort(e, params.row,params.row.index,'cooperationName')}
									>
										{this.operativeTeamList.length != 0
											? this.operativeTeamList.map((item, index) => {
													return <el-option key={index} label={item.cooperationName} value={item.cooperationCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cooperationName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyFront',
          label: '前沿',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
                  return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyFrontList[params.row.index], "num", e)
                            console.log(this.tallyFrontList[params.row.index])
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyFrontList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popoverf}
                    onShow={e => this.setPortData(params.row.tallyFrontList,'front')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyFrontList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureOpenPortEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyFront}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择前沿"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearOpenPortDetail("tallyFront", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyFront", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyFront}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'transport',
          label: '转运',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.transportList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.transportList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
                    v-model={this.popoverz}
                    onShow={e => this.setPortData(params.row.transportList,'transport')}
										popper-class="workTaskEditPopover"
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.transportList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureOpenPortEdit("transport", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("transport", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.transport}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择转运"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearOpenPortDetail("transport", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("transport", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.transport}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyBack',
          label: '后场',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyBackList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyBackList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popoverb}
                    onShow={e => this.setPortData(params.row.tallyBackList,'tallyBack')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyBackList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureOpenPortEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyBack}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择后场"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearOpenPortDetail("tallyBack", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyBack", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyBack}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'supporting',
          label: '辅助',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.supportingList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.supportingList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.portIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popovers}
                    onShow={e => this.setPortData(params.row.supportingList,'supporting')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.supportingList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureOpenPortEdit("supporting", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("supporting", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.supporting}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择辅助"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearOpenPortDetail("supporting", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("supporting", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.supporting}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'laborDispatch',
          label: '劳务',
          width: 130,
          // render: (h,params) => {
          //   let teamListColumns = [
					// 		{
					// 			prop: "deptName",
					// 			label: "劳务队",
					// 		},
					// 		{
					// 			prop: "num",
					// 			label: "人数",
					// 			render: (h, params) => {
					// 				return h("el-input", {
					// 					props: {
					// 						value: params.row.num,
					// 						type: "text",
					// 						size: "mini",
					// 						placeholder: "请输入",
					// 					},
					// 					on: {
					// 						input: e => {
					// 							this.$set(this.laborDispatchList[params.row.index], "num", e)
					// 						},
					// 					},
					// 				})
					// 			},
					// 		},
					// 	]
          //   return (
					// 		<div>
					// 			{this.portIndex === params.row.index ? (
					// 				<el-popover
					// 					placement="bottom"
					// 					width="300"
					// 					trigger="click"
					// 					ref="showTeamOneForEdit"
					// 					popper-class="workTaskEditPopover"
          //           v-model={this.colselabour}
          //           onShow={e => this.setlabourData(params.row.laborDispatchList)}
					// 				>
					// 					<div class="box-infoNew">
					// 						<BaseTable
					// 							data={this.laborDispatchList}
					// 							columns={teamListColumns}
					// 							pagination={false}
					// 							tableHeight={500}
					// 						></BaseTable>
					// 						<div class="btn-sureNew" style={this.btnSureNew}>
					// 							<el-button
					// 								type="primary"
					// 								onClick={e => this.saveLabourData("laborDispatch", params, params.row.index)}
					// 								size="mini"
					// 							>
					// 								确定
					// 							</el-button>
					// 							<el-button
					// 								type="info"
					// 								style={this.btnNew}
					// 								onClick={e => this.cancelTeamForEdit("laborDispatch", params, params.row.index)}
					// 								size="mini"
					// 							>
					// 								取消
					// 							</el-button>
					// 						</div>
					// 					</div>
					// 					<el-input
					// 						v-model={params.row.laborDispatch}
					// 						autocomplete="off"
					// 						size="small"
					// 						slot="reference"
					// 						placeholder="请选择劳务队别"
					// 						suffix-icon="el-icon-arrow-down"
					// 						class="no-border"
					// 						clearable
					// 						onClear={e => this.cleardowmTeamDetail("laborDispatch", params.row.index)}
					// 						onInput={e => this.inputdowmTeamDetail("laborDispatch", e, params.row.index)}
					// 					></el-input>
					// 				</el-popover>
					// 			) : (
					// 				<span>{params.row.laborDispatch}</span>
					// 			)}
					// 		</div>
					// 	)
          // }
        },
        {
          prop: 'foreignTallyCompanyName',
          label: '外理单位'
        },
        {
          prop: 'tallyClerk',
          label: '理货员',
        },
        {
          prop: 'ruler',
          label: '检尺员',
        },
        {
          prop: 'instructorName',
          label: '指导员',
          width: 130,
          // render: (h,params) => {
          //   return (
					// 		<div>
					// 			{this.portIndex === params.row.index ? (
					// 				<el-select
					// 					v-model={params.row.instructorName}
					// 					filterable
					// 					class="no-border"
					// 					value-key="instructorBy"
					// 					clearable
					// 					size="small"
					// 					placeholder="请选择"
          //           onChange={e => this.onChangeSelectPort(e, params.row,params.row.index,'instructorName')}
					// 				>
					// 					{this.guideList.length != 0
					// 						? this.guideList.map((item, index) => {
					// 								return <el-option key={index} label={item.instructorName} value={item}></el-option>
					// 						  })
					// 						: ""}
					// 				</el-select>
					// 			) : (
					// 				<span>{params.row.instructorName}</span>
					// 			)}
					// 		</div>
					// 	)
          // }
        },
        {
          prop: 'workloadPlan',
          label: '计划量',
          render: (h,params) => {
            return (
              <div>
                {this.portIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.workloadPlan,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.openPortTableData[params.row.index], "workloadPlan", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.workloadPlan}</span>
								)}
              </div>
            )
          }
        },
        {
          prop: 'endTimePlan',
          label: '计划完工时间',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.portIndex === params.row.index ? 
                  h('el-date-picker', {
						        props: {
						        	value: params.row.endTimePlan,
						        	type: "datetime",
						        	size: "mini",
						        	placeholder: "请选择",
                      format: 'yyyy-MM-dd hh:mm',
                      valueFormat: 'yyyy-MM-dd hh:mm'
						        },
                    domProps: {
                      style: 'width: 100%'
                    },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.openPortTableData[params.row.index], "endTimePlan", e)
						        	},
						        },
                  }) : (
                    <span>{params.row.endTimePlan}</span>
                  )
                }
              </div>
            )
          }
        },
        {
          prop: 'remark',
          label: '作业要求',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.portIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.remark,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.openPortTableData[params.row.index], "remark", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.remark}</span>
								)}
              </div>
            )
          }
        },
      ],
      openPortselect: [], // 选中的集疏港计划复选框
      popoverf: false,
      popoverz: false,
      popoverb: false,
      popovers: false,
      btnNew: {
				marginLeft: "8px !important",
			},
      traIndex: -1,
      tloading: false,
      transshipmentTableData: [], // 转运
      transshipmentColumns: [
        {
          prop: 'planNo',
          label: '编号',
          width: 140
        },
        {
          prop: 'approvalStatus',
          label: '状态',
          render(h,params) {
            if (params.row.approvalStatus == '1') {
              return h('el-tag', {
                props: {
                  size: 'mini'
                },
                domProps: {
                  innerHTML: '未审核'
                }
              })
            } else if (params.row.approvalStatus == '2') {
              return h('el-tag', {
                props: {
                  size: 'mini',
                  type: 'success'
                },
                domProps: {
                  innerHTML: '已审核'
                }
              })
            }
          }
        },
        {
          prop: 'processName',
          label: '作业过程'
        },
        {
          prop: 'nameVoyage',
          label: '船名航次',
          width: 120
        },
        {
          prop: 'cabinNo',
          label: '舱口',
          width: 120,
          render: (h,params) => {
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-select
										v-model={params.row.cabinNos}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectCabinNo(e,params.row.index,'tra')}
									>
										{this.hatchNoList 
											? this.hatchNoList.map((item, index) => {
													return <el-option key={index} label={item} value={item}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cabinNo}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cargoCategoryName',
          label: '货种',
        },
        {
          prop: 'customerName',
          label: '货代',
          isShort: true,
        },
        {
          prop: 'loadUnload',
          label: '装卸'
        },
        {
          prop: 'berthNo',
          label: '泊位'
        },
        {
          prop: 'storehouseNameSource',
          label: '起始区域',
        },
        {
          prop: 'storehouseNameTarget',
          label: '终点区域',
        },
        {
          prop: 'deptName',
          label: '作业工段',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-select
										v-model={params.row.deptCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectTra(e, params.row,params.row.index,'deptName')}
									>
										{this.deptList 
											? this.deptList.map((item, index) => {
													return <el-option key={index} label={item.deptName} value={item.deptCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.deptName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'cooperationName',
          label: '协力队',
          width: 130,
          render: (h,params) => {
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-select
										v-model={params.row.cooperationCode}
										multiple
                    collapse-tags
										class="no-border"
										value-key="id"
										clearable
										size="small"
										placeholder="请选择"
                    onChange={e => this.onChangeSelectTra(e, params.row,params.row.index,'cooperationName')}
									>
										{this.operativeTeamList.length != 0
											? this.operativeTeamList.map((item, index) => {
													return <el-option key={index} label={item.cooperationName} value={item.cooperationCode}></el-option>
											  })
											: ""}
									</el-select>
								) : (
									<span>{params.row.cooperationName}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyFront',
          label: '前沿',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
                  return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyFrontList[params.row.index], "num", e)
                            console.log(this.tallyFrontList[params.row.index])
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyFrontList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popoverf}
                    onShow={e => this.setTraData(params.row.tallyFrontList,'front')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyFrontList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTraEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyFront", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyFront}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择前沿"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearTraDetail("tallyFront", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyFront", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyFront}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'transport',
          label: '转运',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.transportList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.transportList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
                    v-model={this.popoverz}
                    onShow={e => this.setTraData(params.row.transportList,'transport')}
										popper-class="workTaskEditPopover"
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.transportList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTraEdit("transport", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("transport", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.transport}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择转运"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearTraDetail("transport", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("transport", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.transport}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'tallyBack',
          label: '后场',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.tallyBackList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.tallyBackList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popoverb}
                    onShow={e => this.setTraData(params.row.tallyBackList,'tallyBack')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.tallyBackList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTraEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("tallyBack", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.tallyBack}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择后场"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearTraDetail("tallyBack", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("tallyBack", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.tallyBack}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'supporting',
          label: '辅助',
          width: 130,
          render: (h,params) => {
            let teamListColumns = [
							{
								prop: "equipmentTypeName",
								label: "机械类型",
							},
							{
								prop: "num",
								label: "人数/机械",
								render: (h, params) => {
									return h("div",{},[
                    params.row.equipmentTypeName !== '门机' ?
                      h("el-input", {
										    props: {
										    	value: params.row.num,
										    	type: "text",
										    	size: "mini",
										    	placeholder: "请输入",
										    },
										    on: {
										    	input: e => {
                            console.log(e)
										    		this.$set(this.supportingList[params.row.index], "num", e)
										    	},
										    },
                      }) : 
                      h(
												"el-select",
												{
													props: {
														value: params.row.doorMachineList,
														placeholder: "请选择",
														size: "mini",
														clearable: true,
														multiple: true,
													},
													on: {
														change: e => {
                              console.log(e)
															this.$set(this.supportingList[params.row.index], "doorMachineList", e)
														},
													},
												},
												this.machineTypeList.map(item => {
													return h("el-option", {
														props: {
															value: item.equipmentNo,
															label: item.equipmentNo,
															size: "mini",
														},
													})
												})
											),
                  ])
								},
							},
						]
            return (
							<div>
								{this.traIndex === params.row.index ? (
									<el-popover
										placement="bottom"
										width="300"
										trigger="click"
										ref="showTeamOneForEdit"
										popper-class="workTaskEditPopover"
                    v-model={this.popovers}
                    onShow={e => this.setTraData(params.row.supportingList,'supporting')}
									>
										<div class="box-infoNew">
											<BaseTable
												data={this.supportingList}
												columns={teamListColumns}
												pagination={false}
												tableHeight={500}
											></BaseTable>
											<div class="btn-sureNew" style={this.btnSureNew}>
												<el-button
													type="primary"
													onClick={e => this.sureTraEdit("supporting", params, params.row.index)}
													size="mini"
												>
													确定
												</el-button>
												<el-button
													type="info"
													style={this.btnNew}
													onClick={e => this.cancelTeamForEdit("supporting", params, params.row.index)}
													size="mini"
												>
													取消
												</el-button>
											</div>
										</div>
										<el-input
											v-model={params.row.supporting}
											autocomplete="off"
											size="small"
											slot="reference"
											placeholder="请选择辅助"
											suffix-icon="el-icon-arrow-down"
											class="no-border"
											clearable
											onClear={e => this.clearTraDetail("supporting", params.row.index)}
											onInput={e => this.inputdowmTeamDetail("supporting", e, params.row.index)}
										></el-input>
									</el-popover>
								) : (
									<span>{params.row.supporting}</span>
								)}
							</div>
						)
          }
        },
        {
          prop: 'laborDispatch',
          label: '劳务',
          width: 130,
        },
        {
          prop: 'foreignTallyCompanyName',
          label: '外理单位'
        },
        {
          prop: 'tallyClerk',
          label: '理货员',
        },
        {
          prop: 'ruler',
          label: '检尺员',
        },
        {
          prop: 'instructorName',
          label: '指导员',
          width: 130,
        },
        {
          prop: 'workloadPlan',
          label: '计划量',
          render: (h,params) => {
            return (
              <div>
                {this.traIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.workloadPlan,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.transshipmentTableData[params.row.index], "workloadPlan", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.workloadPlan}</span>
								)}
              </div>
            )
          }
        },
        {
          prop: 'endTimePlan',
          label: '计划完工时间',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.traIndex === params.row.index ? 
                  h('el-date-picker', {
						        props: {
						        	value: params.row.endTimePlan,
						        	type: "datetime",
						        	size: "mini",
						        	placeholder: "请选择",
                      format: 'yyyy-MM-dd hh:mm',
                      valueFormat: 'yyyy-MM-dd hh:mm'
						        },
                    domProps: {
                      style: 'width: 100%'
                    },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.transshipmentTableData[params.row.index], "endTimePlan", e)
						        	},
						        },
                  }) : (
                    <span>{params.row.endTimePlan}</span>
                  )
                }
              </div>
            )
          }
        },
        {
          prop: 'remark',
          label: '作业要求',
          width: 160,
          render: (h,params) => {
            return (
              <div>
                {this.traIndex === params.row.index ? (
                  h("el-input", {
						        props: {
						        	value: params.row.remark,
						        	type: "text",
						        	size: "mini",
						        	placeholder: "请输入",
						        },
						        on: {
						        	input: e => {
                        console.log(e)
						        		this.$set(this.transshipmentTableData[params.row.index], "remark", e)
						        	},
						        },
                  })
                ) : (
									<span>{params.row.remark}</span>
								)}
              </div>
            )
          }
        },
      ],
      transshipmentselect: [], // 选中的转运计划复选框
    }
  },
  activated () {
    var menuArr = []
    var menuId = ''
    if (localStorage.getItem('menuArr')) {
      menuArr = JSON.parse(localStorage.getItem('menuArr'))
    }
    menuArr.map(item => {
      item.children.map(v => {
        if (window.location.href.includes(v.url)) {
          menuId = v.id
        }
      })
    })
    if (menuId) {
      this.menuArr = []
      publicapi.getPermissionsBtn(menuId)
        .then(res => {
          res.data.data.map(item => {
            this.menuArr.push(item.RESOURCENAME)
          })
        }).catch((error) => {})
    }
    if (this.$store.state.app.searchResouce == 'menu') {
      this.queryAll = {
        companyName: '',
        startpage: 1,
       pagesize: 10
      }
    }
    this.getDictData()
    // this.searchData()
    this.queryMachineTypeOne()
    this.getworksection()
    this.queryoperativeteam()
    this.querylabor()
    this.querymachine()
    this.queryWorkPeople()
    this.getScheduleNow()
  },
  created() {
    //  日期默认当天
		let date = new Date()
		let theYear = date.getFullYear() //获取完整的年份(4位)
		let theMonth = date.getMonth() + 1 //获取当前月份(1-12,1代表1月)
		theMonth = theMonth >= 10 ? theMonth : "0" + theMonth
		let theDay = date.getDate() //获取当前日(1-31)
		theDay = theDay >= 10 ? theDay : "0" + theDay
    this.searchForm.workDate = theYear+'-'+theMonth+'-'+theDay
  },
  methods: {
    // 获取当前班次
    getScheduleNow () {
      publicapi.getScheduleNow().then(res => {
        this.searchForm.workTime = res.data.data.scheduleType
      })
    },
    // 查询字典信息
    getDictData () {
      publicapi.getDictData('SCHEDULE').then(res => {
        this.workTimeList = res.data.data.SCHEDULE
      })
    },
    // 查询作业工段
    getworksection () {
      api.getworksection().then(res => {
        this.deptList = res.data.data
      })
    },
    // 查询协力队
    queryoperativeteam () {
      api.queryoperativeteam().then(res => {
        this.operativeTeamList = res.data.data
      })
    },
    // 查询劳务
    querylabor () {
      api.querylabor().then(res => {
        this.labourList = res.data.data
      })
    },
    // 查询机械类型
    querymachine () {
      api.querymachine().then(res => {
        this.machineList = res.data.data
      })
    },
    // 查询机械类型为门机的编号
    queryMachineTypeOne () {
      api.queryMachineTypeOne().then(res => {
        this.machineTypeList = res.data.data
      })
    },
    // 查询指导员
    queryWorkPeople () {
      api.queryWorkPeople().then(res => {
        this.guideList = res.data.data
      })
    },
    // tab页点击事件
    handleClick (val) {
      console.log(val)
      if (val == 'first') {
        this.queryShipPlan()
        this.isShowWorkPlanbtn = true
        this.isShowOddJobbtn = false
        this.isShowOpenPort = false
        this.isShowTra = false
      } else if (val == 'second') {
        this.queryOddJob()
        this.isShowWorkPlanbtn = false
        this.isShowOddJobbtn = true
        this.isShowOpenPort = false
        this.isShowTra = false
      } else if (val == 'third') {
        this.queryOpenPort()
        this.isShowWorkPlanbtn = false
        this.isShowOddJobbtn = false
        this.isShowOpenPort = true
        this.isShowTra = false
      } else if (val == 'four') {
        this.queryTra()
        this.isShowWorkPlanbtn = false
        this.isShowOddJobbtn = false
        this.isShowOpenPort = false
        this.isShowTra = true
      }
    },
    // 分页查询
    sizeChange(val) {
      this.queryall.pagesize = val;
      this.searchData();
    },
    // 分页查询
    pageChange(val) {
      this.queryall.startpage = val;
      this.searchData();
    },
    // 查询主列表
    searchData () {
      if (this.activeName == 'first') {
        this.queryShipPlan()
      } else if (this.activeName == 'second') {
        this.queryOddJob()
      } else if (this.activeName == 'third') {
        this.queryOpenPort()
      } else if (this.activeName == 'four') {
        this.queryTra()
      }
    },
    // 查询船舶计划
    queryShipPlan () {
      this.loading = true
      this.$refs.showFrontEdgeForEdit.clearSelection()
      this.checkData = []
      let params = Object.assign({},this.queryall,this.searchForm)
      api.getWorkPlanData(params).then(res => {
        if (res.data.code != '0000') {
          this.$message.error(res.data.msg)
          return
        }
        this.loading = false
        this.editIndex = -1
        this.tableData = res.data.data.pages
        this.queryall.startpage = res.data.data.pageNum // 当前页
        this.queryall.pagesize = res.data.data.pageSize // 每页多少
        this.queryall.totalNum = res.data.data.totalNum
        this.tableData.forEach(v => {
          v.deptCode = v.deptCode?v.deptCode.split(','):[]
          v.cooperationCode = v.cooperationCode?v.cooperationCode.split(','):[]
        })
      })
    },
    // 双击主列表
    handlerClickdb (row) {
      console.log(row)
      this.editIndex = row.index
    },
    // 选择复选框
    workTaskSelChange (val) {
      console.log(val)
      this.checkData = val
    },
    // 重置搜索信息
    resetSearch () {
      this.searchForm.workDate = ''
      this.searchForm.workTime = ''
    },
    // 导入作业指令
    add () {

    },
    // 获取协力队列表
    getTeamListForEdit (row) {

    },
    // 确认选择前沿/转运/后场/辅助信息
    sureTeamForEdit (type,row,index) {
      var data = []
      if (type == 'tallyFront') {
        data = this.tallyFrontList
      } else if (type == 'transport') {
        data = this.transportList
      } else if (type == 'tallyBack') {
        data = this.tallyBackList
      } else if (type == 'supporting') {
        data = this.supportingList
      }
      console.log(data)
      var showArr = ''
      var chooseArr = []
      for (let i = 0; i < data.length;i++) {
        if (data[i].equipmentTypeName != '门机') {
          if (data[i].num) {
            chooseArr.push(data[i])
            showArr += 
              data[i].equipmentTypeName +
							data[i].num +
							","
          }
        } else if (data[i].equipmentTypeName == '门机') {
          if (data[i].doorMachineList && data[i].doorMachineList.length > 0) {
            for (let j = 0;j < data[i].doorMachineList.length;j++) {
              let door = data[i]
              console.log(door)
              var model = {}
              model.equipmentTypeId = door.equipmentTypeId + ''
              model.equipmentNo = door.doorMachineList[j]
              model.equipmentTypeName = door.equipmentTypeName
              chooseArr.push(model)
              showArr += model.equipmentNo + ','
            }
          }
        }
      }
      if (showArr != "") showArr = showArr.substring(0, showArr.length - 1)
      if (type == 'tallyFront') {
        this.tableData[index].tallyFront = showArr
        this.tableData[index].tallyFrontList = chooseArr
      } else if (type == 'transport') {
        this.tableData[index].transport = showArr
        this.tableData[index].transportList = chooseArr
      } else if (type == 'tallyBack') {
        this.tableData[index].tallyBack = showArr
        this.tableData[index].tallyBackList = chooseArr
      } else if (type == 'supporting') {
        this.tableData[index].supporting = showArr
        this.tableData[index].supportingList = chooseArr
      }
      this.colsePopoer = false
      this.colseback = false,
      this.colsetransport = false,
      this.colsesupport = false
    },
    // 确认劳务数据
    saveLabourData (type,val,index) {
      var data = []
      data = this.laborDispatchList
      var showArr = ''
      var chooseArr = []
      for (let i = 0; i < data.length;i++) {
        if (data[i].num) {
          chooseArr.push(data[i])
          showArr += 
            data[i].deptName +
						data[i].num +
						","
        }
      }
      if (showArr != "") showArr = showArr.substring(0, showArr.length - 1)
      this.tableData[index].laborDispatch = showArr
      this.tableData[index].laborDispatchList = chooseArr
      this.colselabour = false
      
    },
    // 取消选择劳务信息
    cancelTeamForEdit (row) {
      this.colsePopoer = false
      this.colseback = false,
      this.colsetransport = false,
      this.colsesupport = false,
      this.colselabour = false
      this.popoverf = false
      this.popoverz = false
      this.popoverb = false
      this.popovers = false
    },
    // 清空选择的前沿。转运等等信息
    cleardowmTeamDetail (type, index) {
      if (type == "tallyFront") {
				this.$set(this.tableData[index], "tallyFront", "")
				this.$set(this.tableData[index], "tallyFrontList", [])
			} else if (type == 'transport') {
        this.$set(this.tableData[index], "transport", "")
				this.$set(this.tableData[index], "transportList", [])
      } else if (type == 'tallyback') {
        this.$set(this.tableData[index], "tallyback", "")
				this.$set(this.tableData[index], "tallybackList", [])
      } else if (type == 'supporting') {
        this.$set(this.tableData[index], "supporting", "")
				this.$set(this.tableData[index], "supportingList", [])
      } else if (type == 'laborDispatch') {
        this.$set(this.tableData[index], "laborDispatch", "")
				this.$set(this.tableData[index], "laborDispatchList", [])
      }
    },
    // 输入劳务信息
    inputdowmTeamDetail () {

    },
    // 导入作业指令
    importOrder () {
      this.isShow = true;
    },
    // 关闭导入指令前操作
    importBeforeClose () {
      this.isShow = false;
      this.searchData() 
    },
    // 关闭导入指令抽屉
    closeDrawer () {
      this.isShow = false
      this.isShowPaln = false
      this.searchData()
    },
    // 选择工段
    onChangeSelect (val,row,index,type) {
      console.log(val)
      if (type == 'deptName') {
        this.tableData[index].deptName = val.map(v => {
          let obj = this.deptList.filter(j => j.deptCode == v)[0].deptName 
          return obj
        }).join(',')
        this.tableData[index].deptCode = val
      } else if (type == 'cooperationName') {
        this.tableData[index].cooperationName = val.map(v => {
          let obj = this.operativeTeamList.filter(j => j.cooperationCode == v)[0].cooperationName 
          return obj
        }).join(',')
        this.tableData[index].cooperationCode = val
      } else if (type == 'instructorName') {
        this.tableData[index].instructorName = val.instructorName
        this.tableData[index].instructorBy = val.instructorBy
      }
      
    },
    // 设置前沿/转运/后场/辅助数据
    setFrontData (list,type) {
      console.log(list)
      this.querymachine()
      var dataList = []
      var vehicleList = []
      dataList = this.machineList
      if (list && list.length > 0) {
        dataList.forEach(v => {
          if (v.equipmentTypeName == '门机') {
            v.equipmentNo = ''
          }
        })
        dataList.forEach(v => {
          list.forEach(j => {
            if (v.equipmentTypeName == j.equipmentTypeName) {
              v.num = j.num + ''
              v.equipmentNo += j.equipmentNo + ',' + ''
            }
          })
          if (v.equipmentNo) {
            v.equipmentNo = v.equipmentNo.substring(0,v.equipmentNo.length - 1)
          }
        })
      }
      
      console.log(dataList)
      dataList.map(v => {
        var obj = {}
        if (v.equipmentTypeName == '门机') {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.equipmentNo = v.equipmentNo
          obj.doorMachineList = []
          obj.equipmentTypeId = v.equipmentTypeId
          let equipmentNoList = v.equipmentNo ? v.equipmentNo.split(',') : []
          for(let i = 0;i < equipmentNoList.length;i++) {
            var noObj = {}
						noObj = equipmentNoList[i]
						obj.doorMachineList.push(noObj)
          }
        } else {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.num = v.num
          obj.equipmentTypeId = v.equipmentTypeId
        }
        vehicleList.push(obj)
      })
      console.log(vehicleList)
      if (type == 'front') {
        this.tallyFrontList = vehicleList
      } else if (type == 'transport') {
        this.transportList = vehicleList
      } else if (type == 'tallyBack') {
        this.tallyBackList = vehicleList
      } else if (type == 'supporting') {
        this.supportingList = vehicleList
      }
    },
    // 设置劳务数据
    setlabourData (list) {
      var dataList = []
      var vehicleList = []
      dataList = this.labourList
      dataList.map(v => {
        list.map(j => {
          if (v.deptName == j.deptName) {
            v.num = j.num + ''
          }
        })
      })
      dataList.map(v => {
        var obj = {}
        obj.deptId = v.deptId + ''
        obj.deptName = v.deptName
        obj.num = v.num
        vehicleList.push(obj)
      })
      this.laborDispatchList = vehicleList
    },
    // 保存工班计划信息
    saveWorkPlan () {
      if (this.editIndex == -1) {
        return this.$message.info('请先双击一条数据编辑再保存')
      }
      let params = this.tableData[this.editIndex]
      console.log(params)
      // params.laborDispatchList.forEach(v => {
      //   v.deptId = v.deptId + ''
      //   v.num = v.num ? v.num + '' : ''
      // })
      params.tallyFrontList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
        v.equipmentTypeId = v.equipmentTypeId + ''
      })
      params.tallyBackList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
        v.equipmentTypeId = v.equipmentTypeId + ''
      })
      params.transportList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
        v.equipmentTypeId = v.equipmentTypeId + ''
      })
      params.supportingList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
        v.equipmentTypeId = v.equipmentTypeId + ''
      })
      params.cabinNo = params.cabinNos?params.cabinNos.join(','):''
      params.deptCode = params.deptCode?params.deptCode.join(','):''
      params.cooperationCode = params.cooperationCode?params.cooperationCode.join(','):''
      if (!params.deptCode) {
        return this.$message.warning('请选择作业工段')
      }
      api.updatebyid(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.$message.success('保存成功')
        this.searchData()
      })
    },
    // 审核
    auditWorkPlan () {
      if (this.checkData && this.checkData.length == 0) {
        return this.$message.info('请勾选一条数据再进行审核')
      }
      if (this.checkData && this.checkData.length > 1) {
        return this.$message.info('只能审核一条数据')
      }
      this.$confirm('审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.updateStatus(this.checkData[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '审核成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消审核'
          });          
        });
    },
    // 删除
    deletehandlerClick () {
      if (this.checkData && this.checkData.length == 0) {
        return this.$message.info('请勾选一条数据再删除')
      }
      if (this.checkData && this.checkData.length > 1) {
        return this.$message.info('只能删除一条数据')
      }
      this.$confirm('将删除此数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.deletebyid(this.checkData[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    },
    // 赋值工班计划
    copyWorkPlan () {
      if (this.checkData && this.checkData.length == 0) {
        return this.$message.info('请勾选一条数据再复制')
      }
      if (this.checkData && this.checkData.length > 1) {
        return this.$message.info('只能复制一条数据')
      }
      this.$confirm('将复制此数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.copyById(this.checkData[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '复制成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消复制'
          });          
        });
    },
    // 导入上一班次
    importWorkPlan () {
      this.isShowPaln = true
    },
    // 零工双击
    oddJobhandlerClickdb (val) {
      this.oddIndex = val.index
    },
    // 选中复选框
    oddJobselectCheck (val) {
      console.log(val)
      this.oddJobCheck = val
    },
    // 查询零工主列表
    queryOddJob () {
      this.$refs.oddJobPlan.clearSelection()
      this.oddJobCheck = []
      this.oloading = true
      let params = Object.assign({},this.searchForm)
      api.queryApplication(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.oloading = false
        this.oddJobTableData = res.data.data
        this.oddIndex = -1
        this.oddJobTableData.forEach(v => {
          v.deptCode = v.deptCode?v.deptCode.split(','):[]
          v.cooperationCode = v.cooperationCode?v.cooperationCode.split(','):[]
        })
      })
    },
    // 保存零工机械
    sureMachineOddJob (type,row,index) {
      var data = []
      data = this.supportingList
      var showArr = ''
      var chooseArr = []
      for (let i = 0; i < data.length;i++) {
        if (data[i].equipmentTypeName != '门机') {
          if (data[i].num) {
            chooseArr.push(data[i])
            showArr += 
              data[i].equipmentTypeName +
							data[i].num +
							","
          }
        } else if (data[i].equipmentTypeName == '门机') {
          for (let j = 0;j < this.machineTypeList.length;j++) {
            let door = this.machineTypeList[j]
            var model = {}
            model.equipmentTypeId = door.equipmentTypeId + ''
            model.equipmentNo = door.equipmentNo
            model.equipmentTypeName = door.equipmentTypeName
            chooseArr.push(model)
            showArr += door.equipmentNo + ','
          }
        }
      }
      if (showArr != "") showArr = showArr.substring(0, showArr.length - 1)
      this.oddJobTableData[index].supporting = showArr
      this.oddJobTableData[index].supportingList = chooseArr
      this.colsesupport = false
    },
    // 清空零工机械数据
    clearOddJobDetail (index) {
      this.$set(this.oddJobTableData[index], "supporting", "")
			this.$set(this.oddJobTableData[index], "supportingList", [])
    },
    // 选择零工作业工段及协力队
    onChangeSelectOddJob (val,row,index,type) {
      if (type == 'deptName') {
        this.oddJobTableData[index].deptName = val.map(v => {
          let obj = this.deptList.filter(j => j.deptCode == v)[0].deptName 
          return obj
        }).join(',')
        this.oddJobTableData[index].deptCode = val
      } else if (type == 'cooperationName') {
        this.oddJobTableData[index].cooperationName = val.map(v => {
          let obj = this.operativeTeamList.filter(j => j.cooperationCode == v)[0].cooperationName 
          return obj
        }).join(',')
        this.oddJobTableData[index].cooperationCode = val
      }
    },
    // 保存零工计划
    saveOddJob () {
      if (this.oddIndex == -1) {
        return this.$message.info('请先双击一条数据编辑再保存')
      }
      let params = this.oddJobTableData[this.oddIndex]
      console.log(params)
      params.supportingList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
      })
      params.cabinNo = params.cabinNos.join(',')
      params.deptCode = params.deptCode.join(',')
      params.cooperationCode = params.cooperationCode.join(',')
      if (!params.deptCode) {
        return this.$message.warning('请选择作业工段')
      }
      api.updateApplicationPlan(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.$message.success('保存成功')
        this.searchData()
      })
    },
    // 审核零工计划
    auditOddJob () {
      if (this.oddJobCheck && this.oddJobCheck.length == 0) {
        return this.$message.info('请勾选一条数据再进行审核')
      }
      if (this.oddJobCheck && this.oddJobCheck.length > 1) {
        return this.$message.info('只能审核一条数据')
      }
      this.$confirm('审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.updateStatus(this.oddJobCheck[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '审核成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消审核'
          });          
        });
    },
    // 查询集疏港计划
    queryOpenPort () {
      this.$refs.openPort.clearSelection()
      this.openPortselect = []
      let params = Object.assign({},this.searchForm)
      api.queryPort(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.openPortTableData = res.data.data
        this.portIndex = -1
        this.openPortTableData.forEach(v => {
          v.deptCode = v.deptCode?v.deptCode.split(','):[]
          v.cooperationCode = v.cooperationCode?v.cooperationCode.split(','):[]
        })
      })
    },
    // 集疏港双击
    openPortHandlerClickdb (val) {
      console.log(val)
      this.portIndex = val.index
    },
    // 选中集疏港复选框
    openPortselectCheck (val) {
      console.log(val)
      this.openPortselect = val
    },
    // 确认选择前沿/转运/后场/辅助信息 -- 集疏港
    sureOpenPortEdit (type,row,index) {
      var data = []
      if (type == 'tallyFront') {
        data = this.tallyFrontList
      } else if (type == 'transport') {
        data = this.transportList
      } else if (type == 'tallyBack') {
        data = this.tallyBackList
      } else if (type == 'supporting') {
        data = this.supportingList
      }
      var showArr = ''
      var chooseArr = []
      for (let i = 0; i < data.length;i++) {
        if (data[i].equipmentTypeName != '门机') {
          if (data[i].num) {
            chooseArr.push(data[i])
            showArr += 
              data[i].equipmentTypeName +
							data[i].num +
							","
          }
        } else if (data[i].equipmentTypeName == '门机') {
          if (data[i].doorMachineList && data[i].doorMachineList.length > 0) {
            for (let j = 0;j < data[i].doorMachineList.length;j++) {
              let door = data[i]
              var model = {}
              model.equipmentTypeId = door.equipmentTypeId + ''
              model.equipmentNo = door.doorMachineList[j]
              model.equipmentTypeName = door.equipmentTypeName
              chooseArr.push(model)
              showArr += model.equipmentNo + ','
            }
          }
        }
      }
      if (showArr != "") showArr = showArr.substring(0, showArr.length - 1)
      if (type == 'tallyFront') {
        this.openPortTableData[index].tallyFront = showArr
        this.openPortTableData[index].tallyFrontList = chooseArr
      } else if (type == 'transport') {
        this.openPortTableData[index].transport = showArr
        this.openPortTableData[index].transportList = chooseArr
      } else if (type == 'tallyBack') {
        this.openPortTableData[index].tallyBack = showArr
        this.openPortTableData[index].tallyBackList = chooseArr
      } else if (type == 'supporting') {
        this.openPortTableData[index].supporting = showArr
        this.openPortTableData[index].supportingList = chooseArr
      }
      this.popoverf = false
      this.popoverz = false
      this.popoverb = false
      this.popovers = false
    },
    // 清空选择的前沿。转运等等信息 -- 集疏港
    clearOpenPortDetail (type, index) {
      if (type == "tallyFront") {
				this.$set(this.openPortTableData[index], "tallyFront", "")
				this.$set(this.openPortTableData[index], "tallyFrontList", [])
			} else if (type == 'transport') {
        this.$set(this.openPortTableData[index], "transport", "")
				this.$set(this.openPortTableData[index], "transportList", [])
      } else if (type == 'tallyback') {
        this.$set(this.openPortTableData[index], "tallyback", "")
				this.$set(this.openPortTableData[index], "tallybackList", [])
      } else if (type == 'supporting') {
        this.$set(this.openPortTableData[index], "supporting", "")
				this.$set(this.openPortTableData[index], "supportingList", [])
      } else if (type == 'laborDispatch') {
        this.$set(this.openPortTableData[index], "laborDispatch", "")
				this.$set(this.openPortTableData[index], "laborDispatchList", [])
      }
    },
    // 选择工段,协力队相关 -- 集疏港
    onChangeSelectPort (val,row,index,type) {
      console.log(val)
      console.log(row)
      if (type == 'deptName') {
        this.openPortTableData[index].deptName = val.map(v => {
          let obj = this.deptList.filter(j => j.deptCode == v)[0].deptName 
          return obj
        }).join(',')
        this.openPortTableData[index].deptCode = val
      } else if (type == 'cooperationName') {
        this.openPortTableData[index].cooperationName = val.map(v => {
          let obj = this.operativeTeamList.filter(j => j.cooperationCode == v)[0].cooperationName 
          return obj
        }).join(',')
        this.openPortTableData[index].cooperationCode = val
      } else if (type == 'instructorName') {
        this.openPortTableData[index].instructorName = val.instructorName
        this.openPortTableData[index].instructorBy = val.instructorBy
      }
      
    },
    // 设置前沿，转运等字段
    setPortData (list,type) {
      this.querymachine()
      var dataList = []
      var vehicleList = []
      dataList = this.machineList
      if (list && list.length > 0) {
        dataList.forEach(v => {
          if (v.equipmentTypeName == '门机') {
            v.equipmentNo = ''
          }
        })
        dataList.forEach(v => {
          list.forEach(j => {
            if (v.equipmentTypeName == j.equipmentTypeName) {
              v.num = j.num + ''
              v.equipmentNo += j.equipmentNo + ',' + ''
            }
          })
          if (v.equipmentNo) {
            v.equipmentNo = v.equipmentNo.substring(0,v.equipmentNo.length - 1)
          }
        })
      }
      
      console.log(dataList)
      dataList.map(v => {
        var obj = {}
        if (v.equipmentTypeName == '门机') {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.equipmentTypeId = v.equipmentTypeId
          obj.equipmentNo = v.equipmentNo
          obj.doorMachineList = []
          let equipmentNoList = v.equipmentNo ? v.equipmentNo.split(',') : []
          for(let i = 0;i < equipmentNoList.length;i++) {
            var noObj = {}
						noObj = equipmentNoList[i]
						obj.doorMachineList.push(noObj)
          }
        } else {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.equipmentTypeId = v.equipmentTypeId
          obj.num = v.num
        }
        vehicleList.push(obj)
      })
      if (type == 'front') {
        this.tallyFrontList = vehicleList
      } else if (type == 'transport') {
        this.transportList = vehicleList
      } else if (type == 'tallyBack') {
        this.tallyBackList = vehicleList
      } else if (type == 'supporting') {
        this.supportingList = vehicleList
      }
    },
    // 保存集疏港
    saveOpenPort () {
      if (this.portIndex == -1) {
        return this.$message.info('请先双击一条数据编辑再保存')
      }
      let params = this.openPortTableData[this.portIndex]
      console.log(params)
      params.tallyBackList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
      })
      if (params.supportingList && params.supportingList.length > 0) {
        params.supportingList.forEach(v => {
          v.num = v.num ? v.num + '' : ''
        })
      }
      params.deptCode = params.deptCode?params.deptCode.join(','):''
      params.cabinNo = params.cabinNos?params.cabinNos.join(','):''
      params.cooperationCode = params.cooperationCode?params.cooperationCode.join(','):''
      if (!params.deptCode) {
        return this.$message.warning('请选择作业工段')
      }
      api.updatePort(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.$message.success('保存成功')
        this.searchData()
      })
    },
    // 审核集疏港
    auditOpenPort () {
      if (this.openPortselect && this.openPortselect.length == 0) {
        return this.$message.info('请勾选一条数据再进行审核')
      }
      if (this.openPortselect && this.openPortselect.length > 1) {
        return this.$message.info('只能审核一条数据')
      }
      this.$confirm('审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.updateStatus(this.openPortselect[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '审核成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消审核'
          });          
        });
    },
    // 选择舱口号
    onChangeSelectCabinNo (val,index,flag) {
      if (flag == 'ship') {
        this.tableData[index].cabinNos = val
      }
      if (flag == 'odd') {
        this.oddJobTableData[index].cabinNos = val
      }
      if (flag == 'port') {
        this.openPortTableData[index].cabinNos = val
      }
      if (flag == 'tra') {
        this.transshipmentTableData[index].cabinNos = val
      }
    },
    // 点击行选中复选框
    handlerClickA (val) {
      this.$refs.showFrontEdgeForEdit.toggleRowSelection(val)
    },
    // 点击行选中复选框
    handlerClickB (val) {
      this.$refs.oddJobPlan.toggleRowSelection(val)
    },
    // 点击行选中复选框
    handlerClickC (val) {
      this.$refs.openPort.toggleRowSelection(val)
    },
    // 点击行选中复选框
    handlerClickD (val) {
      this.$refs.transshipment.toggleRowSelection(val)
    },
    // 查询转运计划
    queryTra () {
      this.$refs.transshipment.clearSelection()
      this.transshipmentselect = []
      let params = Object.assign({},this.searchForm)
      api.queryTransportPlan(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.transshipmentTableData = res.data.data
        this.traIndex = -1
        this.transshipmentTableData.forEach(v => {
          v.deptCode = v.deptCode?v.deptCode.split(','):[]
          v.cooperationCode = v.cooperationCode?v.cooperationCode.split(','):[]
        })
      })
    },
    // 选中的转运
    transshipmentselectCheck (val) {
      this.transshipmentselect = val
    },
    // 转运计划双击
    transshipmentHandlerClickdb (val) {
      this.traIndex = val.index
    },
    // 选择工段,协力队相关 -- 转运
    onChangeSelectTra (val,row,index,type) {
      console.log(val)
      console.log(row)
      if (type == 'deptName') {
        this.transshipmentTableData[index].deptName = val.map(v => {
          let obj = this.deptList.filter(j => j.deptCode == v)[0].deptName 
          return obj
        }).join(',')
        this.transshipmentTableData[index].deptCode = val
      } else if (type == 'cooperationName') {
        this.transshipmentTableData[index].cooperationName = val.map(v => {
          let obj = this.operativeTeamList.filter(j => j.cooperationCode == v)[0].cooperationName 
          return obj
        }).join(',')
        this.transshipmentTableData[index].cooperationCode = val
      } else if (type == 'instructorName') {
        this.transshipmentTableData[index].instructorName = val.instructorName
        this.transshipmentTableData[index].instructorBy = val.instructorBy
      }
      
    },
    // 设置前沿，转运等字段 -- 转运
    setTraData (list,type) {
      this.querymachine()
      var dataList = []
      var vehicleList = []
      dataList = this.machineList
      if (list && list.length > 0) {
        dataList.forEach(v => {
          if (v.equipmentTypeName == '门机') {
            v.equipmentNo = ''
          }
        })
        dataList.forEach(v => {
          list.forEach(j => {
            if (v.equipmentTypeName == j.equipmentTypeName) {
              v.num = j.num + ''
              v.equipmentNo += j.equipmentNo + ',' + ''
            }
          })
          if (v.equipmentNo) {
            v.equipmentNo = v.equipmentNo.substring(0,v.equipmentNo.length - 1)
          }
        })
      }
      
      console.log(dataList)
      dataList.map(v => {
        var obj = {}
        if (v.equipmentTypeName == '门机') {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.equipmentTypeId = v.equipmentTypeId
          obj.equipmentNo = v.equipmentNo
          obj.doorMachineList = []
          let equipmentNoList = v.equipmentNo ? v.equipmentNo.split(',') : []
          for(let i = 0;i < equipmentNoList.length;i++) {
            var noObj = {}
						noObj = equipmentNoList[i]
						obj.doorMachineList.push(noObj)
          }
        } else {
          obj.equipmentTypeName = v.equipmentTypeName
          obj.equipmentTypeId = v.equipmentTypeId
          obj.num = v.num
        }
        vehicleList.push(obj)
      })
      if (type == 'front') {
        this.tallyFrontList = vehicleList
      } else if (type == 'transport') {
        this.transportList = vehicleList
      } else if (type == 'tallyBack') {
        this.tallyBackList = vehicleList
      } else if (type == 'supporting') {
        this.supportingList = vehicleList
      }
    },
    // 确认选择前沿/转运/后场/辅助信息 -- 转运
    sureTraEdit (type,row,index) {
      var data = []
      if (type == 'tallyFront') {
        data = this.tallyFrontList
      } else if (type == 'transport') {
        data = this.transportList
      } else if (type == 'tallyBack') {
        data = this.tallyBackList
      } else if (type == 'supporting') {
        data = this.supportingList
      }
      var showArr = ''
      var chooseArr = []
      for (let i = 0; i < data.length;i++) {
        if (data[i].equipmentTypeName != '门机') {
          if (data[i].num) {
            chooseArr.push(data[i])
            showArr += 
              data[i].equipmentTypeName +
							data[i].num +
							","
          }
        } else if (data[i].equipmentTypeName == '门机') {
          if (data[i].doorMachineList && data[i].doorMachineList.length > 0) {
            for (let j = 0;j < data[i].doorMachineList.length;j++) {
              let door = data[i]
              var model = {}
              model.equipmentTypeId = door.equipmentTypeId + ''
              model.equipmentNo = door.doorMachineList[j]
              model.equipmentTypeName = door.equipmentTypeName
              chooseArr.push(model)
              showArr += model.equipmentNo + ','
            }
          }
        }
      }
      if (showArr != "") showArr = showArr.substring(0, showArr.length - 1)
      if (type == 'tallyFront') {
        this.transshipmentTableData[index].tallyFront = showArr
        this.transshipmentTableData[index].tallyFrontList = chooseArr
      } else if (type == 'transport') {
        this.transshipmentTableData[index].transport = showArr
        this.transshipmentTableData[index].transportList = chooseArr
      } else if (type == 'tallyBack') {
        this.transshipmentTableData[index].tallyBack = showArr
        this.transshipmentTableData[index].tallyBackList = chooseArr
      } else if (type == 'supporting') {
        this.transshipmentTableData[index].supporting = showArr
        this.transshipmentTableData[index].supportingList = chooseArr
      }
      this.popoverf = false
      this.popoverz = false
      this.popoverb = false
      this.popovers = false
    },
    // 清空选择的前沿。转运等等信息 -- 转运
    clearTraDetail (type, index) {
      if (type == "tallyFront") {
				this.$set(this.transshipmentTableData[index], "tallyFront", "")
				this.$set(this.transshipmentTableData[index], "tallyFrontList", [])
			} else if (type == 'transport') {
        this.$set(this.transshipmentTableData[index], "transport", "")
				this.$set(this.transshipmentTableData[index], "transportList", [])
      } else if (type == 'tallyback') {
        this.$set(this.transshipmentTableData[index], "tallyback", "")
				this.$set(this.transshipmentTableData[index], "tallybackList", [])
      } else if (type == 'supporting') {
        this.$set(this.transshipmentTableData[index], "supporting", "")
				this.$set(this.transshipmentTableData[index], "supportingList", [])
      } else if (type == 'laborDispatch') {
        this.$set(this.transshipmentTableData[index], "laborDispatch", "")
				this.$set(this.transshipmentTableData[index], "laborDispatchList", [])
      }
    },
    // 保存转运
    savetransshipment () {
      if (this.traIndex == -1) {
        return this.$message.info('请先双击一条数据编辑再保存')
      }
      let params = this.transshipmentTableData[this.traIndex]
      console.log(params)
      params.tallyBackList.forEach(v => {
        v.num = v.num ? v.num + '' : ''
      })
      if (params.supportingList && params.supportingList.length > 0) {
        params.supportingList.forEach(v => {
          v.num = v.num ? v.num + '' : ''
        })
      }
      params.deptCode = params.deptCode?params.deptCode.join(','):''
      params.cabinNo = params.cabinNos?params.cabinNos.join(','):''
      params.cooperationCode = params.cooperationCode?params.cooperationCode.join(','):''
      if (!params.deptCode) {
        return this.$message.warning('请选择作业工段')
      }
      api.updateTransportPlan(params).then(res => {
        if (res.data.code != '0000') {
          return this.$message.error(res.data.msg)
        }
        this.$message.success('保存成功')
        this.searchData()
      })
    },
    // 审核转运
    audittransshipment () {
      if (this.transshipmentselect && this.transshipmentselect.length == 0) {
        return this.$message.info('请勾选一条数据再进行审核')
      }
      if (this.transshipmentselect && this.transshipmentselect.length > 1) {
        return this.$message.info('只能审核一条数据')
      }
      this.$confirm('审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          api.updateStatus(this.transshipmentselect[0].id).then(res => {
            if (res.data.code != '0000') {
              return this.$message.error(res.data.msg)
            }
            this.searchData()
            this.$message({
              type: 'success',
              message: '审核成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消审核'
          });          
        });
    },
  }
}
</script>
<style lang="less" scoped>
@import "../../../assets/searchfrom.less";
@import "./index.less";
</style>
